import urllib.request

url = "https://dianying.taobao.com/showAction.json?_ksTS=1727622666988_64&jsoncallback=jsonp65&action=showAction&n_s=new&event_submit_doGetSoon=true"

headers = {
    # 'authority': 'dianying.taobao.com',
    # 'accept': 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01',
    # 'accept-language': 'zh-CN,zh;q=0.9',
    'cookie': 't=f98ac41bd340b1d4fd330acb29e6c95d; cookie2=17adf58f1a7bfee9d37b3e009fc9ae87; v=0; _tb_token_=b5e1a463743e; cna=tE6KHgbNck0CAXju4Ssq0L66; xlly_s=1; tb_city=110100; tb_cityName="sbG+qQ=="; isg=BEtLn0uXqeulTfU_zqtBe6pJ2u814F9i7qcXmb1KgQrh3Go-RbG-sgc_ttwyfLda',
    'referer': 'https://dianying.taobao.com/',
    # 'sec-ch-ua': '"Chromium";v="109", "Not_A Brand";v="99"',
    # 'sec-ch-ua-mobile': '?0',
    # 'sec-ch-ua-platform': '"Windows"',
    # 'sec-fetch-dest': 'empty',
    # 'sec-fetch-mode': 'cors',
    # 'sec-fetch-site': 'same-origin',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
    # 'x-requested-with': 'XMLHttpRequest',
}

request = urllib.request.Request(url=url, headers=headers)

response = urllib.request.urlopen(request)

content = response.read().decode('utf-8')

# 字符串切割
content = content.split('(')[1].split(')')[0]

with open('taopiaopiao.json', 'w', encoding='utf-8') as f:
    f.write(content)
